﻿using CommonEntity;
using Microsoft.AspNetCore.Mvc;
using NetCore6WebAPITestOneRequestEntity;
using NetCroe6WebAPITestOneBusiness;
using System.ComponentModel.DataAnnotations;

namespace NetCroe6WebAPITestOne.Controllers
{
    [ApiController]
    [Route("ueerlogin")]

    public class UserLoginController:ControllerBase
    {
        UserinfoBusiness _userinfoBusiness;

        public UserLoginController(UserinfoBusiness userinfoBusiness)
        {
            _userinfoBusiness = userinfoBusiness;
        }

        /// <summary>
        /// swagger获取token
        /// </summary>
        /// <param name="userinfo"></param>
        /// <returns></returns>
        [HttpPost("UserLogin")]
        public ViewModelBase UserLogin(UserLoginViewModel userinfo) { 
            return _userinfoBusiness.UserLogin(userinfo);
        }

        /// <summary>
        /// swagger获取token
        /// </summary>
        /// <param name="username"></param>
        /// <param name="userpwd"></param>
        /// <returns></returns>
        [HttpGet("UserSwaggerLoginPrivate")]
        public ViewModelBase UserSwaggerLoginPrivate([Required]string username, [Required] string userpwd)
        {
            return _userinfoBusiness.UserSwaggerLogin(new UserLoginViewModel() { 
                OpenLine="swagger",UserName= username,
                UserPwd= userpwd
            });
        }

        /// <summary>
        /// System.IdentityModel.Tokens.Jwt获取token
        /// </summary>
        /// <param name="username"></param>
        /// <param name="userpwd"></param>
        /// <returns></returns>
        [HttpGet("MicsoftAuthExp")]
        public ViewModelBase MicsoftAuthExp(string username,string userpwd)
        {
            return _userinfoBusiness.MicsoftAuthExp(username, userpwd);
        }

        /// <summary>
        /// System.IdentityModel.Tokens.Jwt 校验jwt加密的token
        /// </summary>
        /// <param name="jwt"></param>
        /// <returns></returns>
        [HttpGet("CheckMicsoftAuthExp")]
        public ViewModelBase CheckMicsoftAuthExp(string jwt)
        {
            return _userinfoBusiness.CheckMicsoftAuthExp(jwt);
        }
    }
}
